<!--
 * @: 
 * @Version: 1.0
 * @Autor: ziwei
 * @Date: 2021-10-14 11:19:36
 * @LastEditors: ziwei
 * @LastEditTime: 2021-10-14 13:57:19
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=<device-width>, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var merge = function (nums1, m, nums2, n)
    {
      let len1 = m -1;
      let len2 = n -1;
      let cur = m + n - 1;
      let left = [];
      while (len2 > -1 && len1 > -1) {
        if (nums1[len1] < nums2[len2]) {
          nums1[cur] = nums2[len2]
          len2--
        } else {
          nums1[cur] = nums1[len1]
          len1--
        }
        cur--
      }
      while(len2>-1){
        nums1[len2] = nums2[len2--]
      }
      return nums1
    };

    let a = merge([0],0,[1],1);
    console.log(a);
  </script>
</body>

</html>